const { defineConfig } = require('@vue/cli-service')

// 不同环境的代理目标
const proxyTargets = {
  development: 'http://admpre.goldfull.cc/',
  preview: 'http://admpre.goldfull.cc/',
  production: 'https://adm.goldfull.cc/'
};

// 获取当前环境
const env = process.env.NODE_ENV || 'development';

module.exports = defineConfig({
  transpileDependencies: true,
  chainWebpack: config => {
    config
      .plugin('html')
      .tap(args => {
        args[0].title = process.env.NODE_ENV=='production'?'后台管理系统':'[测试版]后台管理系统'
        return args
      })
  },
  devServer: {
    proxy: {
      '/api': {
        target: proxyTargets[env],
        changeOrigin: true,
        // pathRewrite: { '^/api': '' }
      }
    }
  }
})